<template>
    <div>
        <Modal v-model="modal1" title="提示" @on-ok="ok" @on-cancel="cancel">
            <p>你确定退出本页面吗</p>
        </Modal>
    </div>
</template>
<script>
export default {
    name: "backView",
    data() {
        return {
            modal1: false,
            isCanBack: false,
        };
    },
    methods: {
        ok() {
            this.isCanBack = true;
            this.$router.back();
        },
        cancel() {},
    },
    beforeRouteLeave(to, from, next) {
        if (this.isCanBack) {
            next(true);
        } else {
            this.modal1 = true;
            next(false);
        }
    },
};
</script>